import { FieldRule } from 'vant'

const mobileRules: FieldRule[] = [
  { required: true, message: '手机号不可为空' },
  { pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确' }
]

const passwrodRule: FieldRule[] = [
  { required: true, message: '密码不可为空' },
  { pattern: /^\w{8,24}$/, message: '密码长度为8-24位' }
]

const codeRules: FieldRule[] = [
  { required: true, message: '验证码不可为空' },
  { pattern: /^\d{6}$/, message: '验证码长度为6位' }
]

const nameRule: FieldRule[] = [
  { required: true, message: '姓名不可为空' },
  { pattern: /^(?:[\u4e00-\u9fa5·]{2,16})$/, message: '姓名格式不正确' }
]

const idCardRule: FieldRule[] = [
  { required: true, message: '身份证号不可为空' },
  {
    pattern:
      /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
    message: '身份证号格式不正确'
  }
]
export { mobileRules, passwrodRule, codeRules, nameRule, idCardRule }
